package hcn.protocol.brandnew.zhenliao.jianyan;

import com.fasterxml.jackson.annotation.JsonFormat;
import ctd.util.xml.jaxb.DateTimeAdapter;
import lombok.Data;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;
import java.util.List;
import org.atag.sysrouter.annotation.DictionaryMapping;

/**
 * 检验危急值查询-响应消息(成功) - ODS_03050301_SUC
 *
 * @author enjoyLife
 */
@Data
@XmlRootElement(name = "Data")
@XmlAccessorType(XmlAccessType.FIELD)
public class LabWarnResultQueryResponse {

    /**
     * 记录集合
     */
    @XmlElementWrapper(name = "Datalists")
    @XmlElement(name = "Datalist")
    private List<Datalist> datalists;

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Patient {

        /**
         * 患者姓名
         */
        @XmlElement(name = "Name")
        private String name;
        /**
         * 性别代码
         */
        @XmlElement(name = "Sex")
        private String sex;

        @XmlElement(name = "AgeValue")
        private String ageValue;

        @XmlElement(name = "AgeUnit")
        private String ageUnit;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Visit {

        /**
         * 就诊流水号
         */
        @XmlElement(name = "VisitId")
        private String visitId;
        /**
         * 就诊机构代码
         */
        @XmlElement(name = "VisitOrganization")
        private String visitOrganization;
        /**
         * 患者类型代码
         */
        @XmlElement(name = "PatientType")
        @DictionaryMapping("CV09_00_404")
        private String patientType;
        /**
         * 患者类型名称
         */
        @XmlElement(name = "PatientTypeName")
        private String patientTypeName;
        /**
         * 门（急）诊号
         */
        @XmlElement(name = "ClinicId")
        private String clinicId;
        /**
         * 住院号
         */
        @XmlElement(name = "HospizationId")
        private String hospizationId;
        /**
         * 科室代码
         */
        @XmlElement(name = "DeptCode")
        private String deptCode;
        /**
         * 病床号
         */
        @XmlElement(name = "SickbedId")
        private String sickbedId;

        @XmlElement(name = "MedicalCardId")
        private String medicalCardId;

        @XmlElement(name = "DeptCodeName")
        private String deptCodeName;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class LabWarnRecord {

        /**
         * 危急值报告编号
         */
        @XmlElement(name = "WarnId")
        private String warnId;
        /**
         * 检验条码号
         */
        @XmlElement(name = "BarcodeNo")
        private String barcodeNo;
        /**
         * 检验标本号
         */
        @XmlElement(name = "SampleNo")
        private String sampleNo;
        /**
         * 危急值发布机构代码
         */
        @XmlElement(name = "ReportOrganization")
        private String reportOrganization;
        /**
         * 发布科室代码
         */
        @XmlElement(name = "ReportDept")
        private String reportDept;
        /**
         * 发布医师签名
         */
        @XmlElement(name = "ReportDoctor")
        private String reportDoctor;
        /**
         * 发布日期时间
         */
        @XmlElement(name = "ReportTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date reportTime;
        /**
         * 危急值需通知医师代码
         */
        @XmlElement(name = "NoticeDoctor")
        private String noticeDoctor;
        /**
         * 申请项目名称
         */
        @XmlElement(name = "ExamText")
        private String examText;
        /**
         * 检验项目名称
         */
        @XmlElement(name = "TestName")
        private String testName;
        /**
         * 检验项目代码
         */
        @XmlElement(name = "TestID")
        private String testID;
        /**
         * 危急值提示信息
         */
        @XmlElement(name = "WarnInfo")
        private String warnInfo;
        /**
         * 检验结果
         */
        @XmlElement(name = "TestResult")
        private String testResult;
        /**
         * 检验结果计量单位
         */
        @XmlElement(name = "ResultUnit")
        private String resultUnit;
        /**
         * 危急值阈值范围
         */
        @XmlElement(name = "ReferenceRange")
        private String referenceRange;
        /**
         * 医师处理标志
         */
        @XmlElement(name = "DoctorTreatSign")
        private String doctorTreatSign;
        /**
         * 处理医师代码
         */
        @XmlElement(name = "TreatDoctor")
        private String treatDoctor;
        /**
         * 医师处理时间
         */
        @XmlElement(name = "DoctorTreatTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date doctorTreatTime;
        /**
         * 医师处理结果
         */
        @XmlElement(name = "DoctorTreatResult")
        private String doctorTreatResult;
        /**
         * 护士处理标志
         */
        @XmlElement(name = "NurseTreatSign")
        private String nurseTreatSign;
        /**
         * 处理护士代码
         */
        @XmlElement(name = "TreatNurse")
        private String treatNurse;
        /**
         * 护士处理时间
         */
        @XmlElement(name = "NurseTreatTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date nurseTreatTime;
        /**
         * 护士处理结果
         */
        @XmlElement(name = "NurseTreatResult")
        private String nurseTreatResult;

        //以下字段模型中不存在
        @XmlElement(name = "NurseTreatResult")
        private String RemarkInfo;

        /**
         * 多耐药
         */
        private String ExamText;
        private String WarnInfo;
        private String TreatDoctorName;
        private String RequestDoctor;
        private String RequestDoctorName;
        private String RequestDept;
        private String RequestDeptName;
        private String ReportDeptName;
        private String NoticeDoctorName;
    }


    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Datalist {

        /**
         * 患者基本信息
         */
        @XmlElement(name = "Patient")
        private Patient patient;
        /**
         * 就诊摘要
         */
        @XmlElement(name = "Visit")
        private Visit visit;
        /**
         * 危急值集合
         */
        @XmlElementWrapper(name = "LabWarnRecords")
        @XmlElement(name = "LabWarnRecord")
        private List<LabWarnRecord> labWarnRecords;
    }

}
